import React from 'react';
import style from './style.styl';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'
import * as reviewAction from '../../../../actions/review.action' 

import {TreeList,Button} from '../../../../ui-components';

import {makeTeamTree} from '../../../team/TeamManage';
import ReviewHeader from '../tool/ReviewHeader';
import ReviewAdminItem from './ReviewAdminItem';

@connect(({review}) => ({review}),dispatch => ({actions: bindActionCreators({...reviewAction }, dispatch)}))
class ReviewAdmin extends React.Component {
  static contextTypes = {
    router: React.PropTypes.object
  }
  constructor(props) {
    super(props);
    this.displayName = 'ReviewAdmin';
    this.state = {
      fields: {
        team: []
      }
    }
  }
  componentDidMount() {
    this.props.actions.fetchReviewList({
      statuses: '1,2,3,4',
      pageNumber: 1,
      pageSize: 10000,
      type: 2,
    }) 
  }
  componentWillUnmount() {
    this.props.actions.cleanReviewList();
  }
  updateField = (value) => {
    this.setState({
      fields:{
        ...this.state.fields,
        ...value,
      }
    });
  }
  goBack = () => {
    this.context.router.push(`/review/index/default`);
  } 
  addReview = () => {
    this.context.router.push(`/review/admin/add`);
  } 
  render() {
    const {
      templates
    } = this.props.review;
    const {
      reviewTemplates
    } = templates;
    return (
      <div>
        <ReviewHeader title={'反馈活动管理'} goBack={this.goBack} 
          rightBtn={
            <Button label={'发起反馈活动'} className={style['r-btn']} onClick={this.addReview} />
          }
        />
        {
          reviewTemplates.map((v, i) => {
            return <ReviewAdminItem item={v} />
          })
        }
      </div>
    );
    /*
    return (
      <TreeList
        className={style['tree-list']} width={260}
        onClick={value => this.updateField({'team': value})}
        root={rootTeam}
        label="调岗后部门"
        placeholder={'默认全部门'}
        mulit
        value={this.state.fields.team}
      />
    );
    */
  }
}

export default ReviewAdmin;
